﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utility.Configuration.Provider;
using System.Windows.Forms;
using TimeTracker.Provider;

namespace TimeTracker
{
    public partial class SkinManager : Utility.Patterns.Singleton<SkinManager>
    {

        private ProviderManager<System.Configuration.Provider.ProviderBase> providerManager;
        protected ProviderManager<System.Configuration.Provider.ProviderBase> ProviderManager
        {
            get
            {
                if (this.providerManager == null)
                {
                    this.providerManager = new ProviderManager<System.Configuration.Provider.ProviderBase>("skinProviders");
                }

                return this.providerManager;
            }
        }

        private TimeTracker.SkinProvider.IProvider provider = null;
        protected TimeTracker.SkinProvider.IProvider Provider
        {
            get
            {
                string setProvider = Properties.Settings.Default["SkinProvider"].ToString();

                if (this.provider != null)
                {
                    string currentProvider = this.ProviderManager.Provider.Name;

                    if (currentProvider != setProvider)
                    {
                        this.provider = null;
                    }
                }

                if (this.provider == null)
                {
                    this.provider = (TimeTracker.SkinProvider.IProvider)this.ProviderManager.Providers[setProvider];
                }

                return this.provider;
            }
        }

        public SkinManager()
        {

        }

        public void SkinNode(TreeNode node, GroupByEnumeration groupBy)
        {
            this.Provider.SkinTreeNode(node, groupBy);
        }

        public void InitializeTreeView(TreeView treeView)
        {
            this.Provider.InitializeTreeView(treeView);
        }
    }
}
